
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function(){

    $('.cat').click(function(){

        var cat =this.id;
        var data = 'category=' + cat;
        $.ajax({
        type:"GET",
        url:"/user/productajax",
        data: data,
        success: function (html) {
            $('#message').html(html);
            addfun();
        }
       });
        return false;
    });

    addfun();
    remfun();
    buyfun();

});

function remfun(){
$('a.removefromcart').click(function(){

        var pro =this.id;
       
        var data = 'pro_id= '+ pro;
        $.ajax({
        type:"Post",
        url:"/user/removefromcartajax",
        data: data,
        success: function (html) {
        $('#prod').html(html);
        remfun();
        }
        });
        return false;
    });
}

function addfun()
{
    $('a.add').click(function(){

        var proid =this.id;
        var data = 'proid=' + proid;
        $.ajax({
        type:"GET",
        url:"/user/productajax",
        data: data,
        success: function (html) {
            return false;
        }
        });
        return false;
    });
}

function buyfun(){
        $('a.buy').click(function(){
        var data = 'pro_id';
        $.ajax({
        type:"Post",
        url:"/user/buyajax",
        data: data,
        success: function (html) {
        $('#prod').html(html);
        buyfun();
        }
        });
        return false;
             });

    }


